<%@ include file="/taglibs.jsp"%>
<%@ taglib prefix="fn" uri="http://java.sun.com/jsp/jstl/functions" %>
<fmt:message key="date.format" var="df" scope="page"/>
<head>
	<title><fmt:message key="statisticsFileByUser.form.title"/></title>
</head>

<s:form name="statisticsByUserForm" action="showStatisticsByUser" method="post" validate="true">
<table class="table">
<tr>
	<td width="130px">
        <s:property value="getText('statisticsFileByUser.form.label.selectgroup')"/>
    </td>
	<td>
		<s:select name="groupId" list="lstDepartments" listKey="id" listValue="name" theme="simple" headerKey="%{getText('select.default.key')}" headerValue="%{getText('select.default.value')}"/>
	</td>
	<td  width="80px">
        <s:property value="getText('statisticsFileByUser.form.label.selectuser')"/>
    </td>
	<td>
		<s:select headerKey="%{getText('select.default.key')}" headerValue="%{getText('select.default.value')}"
				         list="listUser" theme="simple"
				         listValue="name"
				         name="userId" 
						 listKey="value" />
	</td>
</tr>
<tr>
	<td>
        <s:property value="getText('report.fromdate')"/>
    </td>
    <td>
        <s:textfield id="fromDate" readonly="true" name="fromDate" size="11" theme="simple" required="true"/>
    </td>
	<td >
        <s:property value="getText('report.todate')"/>
    </td>
    <td >
        <s:textfield id="toDate" name="toDate" readonly="true" size="11" theme="simple" required="true"/>
    </td>     
</tr>   
<tr>
			<td colspan="4">

				<button type="submit" onclick="this.blur()" class="button"
					name="reportOnTime">
					<fmt:message key="button.execute.title"></fmt:message>
					<img src="${ctx}/images/report.png" align="left" height="20"
						width="20">
				</button></td>
		</tr>
   </table>

</s:form>
<s:set var="item_name" value="%{getText('file.item_name')}" scope="page"></s:set>
<s:set var="items_name" value="%{getText('file.items_name')}" scope="page"></s:set>
<s:set name="resultFileByUser" value="resultFileByUser" scope="request"/>
<display:table  name="resultFileByUser" class="table" requestURI="" id="resultFileByUser" export="false" pagesize="10" >
	<display:setProperty name="paging.banner.item_name" value="${item_name}"/>
	<display:setProperty name="paging.banner.items_name" value="${items_name}"/>
	
    <display:column property="submitter" sortable="false" media="html" titleKey="file.submitter" />
    <display:column property="receivedDate" sortable="false" media="html" titleKey="statisticsFileByUser.form.table.header.receivedDate" />
    <display:column property="approvedDate" sortable="false" media="html" titleKey="statisticsFileByUser.form.table.header.approvedDate" />
    <display:column property="regulationTime" sortable="false" media="html" titleKey="statisticsFileByUser.form.table.header.regulationTime" />
    <display:column property="inprogress" sortable="false" media="html" titleKey="statisticsFileByUser.form.table.header.inprogress" />
</display:table>

<script type="text/javascript">//<![CDATA[
$(document).ready(function (){
	var currentTime = new Date();
	var month = currentTime.getMonth() + 1;
	var day = currentTime.getDate();
	if(month < 10) month = "0" + month;
	if(day < 10) day = "0" + day;
	var year = currentTime.getFullYear();
	
	var today = day + "/" + month + "/" + year;
	
	if($("#fromDate").val()=="")
  		$("#fromDate").val(today);
	
	if($("#toDate").val()=="")
  		$("#toDate").val(today);
});
                                          
                                          
var groupSel=null;
	$('select[name="groupId"]').change(function(){
		if ($(this).val() != "0") {
			$.blockUI({ message: ajaxAnimation }); 
			$.ajax({
			  url: 'searchUserByGroup.html',
			  data : {'groupId' : $(this).val()},
			  dataType : 'json',
			  success: function(data) {
				  	groupSel = new Option("L\u1EF1a ch\u1ECDn", "-1");	
				  	var groupHtml = groupSel;
					$.each(data.listUser, function() {
						groupHtml += '<option value="' + this.value + '">' + this.name + '</option>';
					});			 
					$('select[name="userId"]').html(groupHtml);										
			  }
			});
		}
	});                                      
      var cal = Calendar.setup({
          onSelect: function(cal) { cal.hide();},
      });
      cal.manageFields("fromDate","fromDate","%d/%m/%Y");
      cal.manageFields("toDate","toDate","%d/%m/%Y");
      
    //]]></script>